import { IPSAppDEFLogic } from '../../app/dataentity/ipsapp-deflogic';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSDEField } from '../defield/ipsdefield';
import { IPSDEFLogic } from './ipsdeflogic';
import { PSDELogicImpl } from './psdelogic-impl';

export class PSDEFLogicImpl extends PSDELogicImpl implements IPSDEFLogic, IPSAppDEFLogic {
  get dEFLogicMode(): 'COMPUTE' | 'DEFAULT' | 'ONCHANGE' | 'CHECK' | 'USER' | 'USER2' | 'USER3' | 'USER4' {
    return this.M.dEFLogicMode;
  }

  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    this.psappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getPSAppDEField') as IPSAppDEField;
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定应用实体属性');
    }
    return value;
  }

  protected psdefield: IPSDEField | null = null;

  getPSDEField(): IPSDEField | null {
    if (this.psdefield != null) return this.psdefield;
    const value = this.M.getPSDEField;
    if (value == null) {
      return null;
    }
    this.psdefield = this.getPSModel4('dataentity.defield.IPSDEField', value, 'getPSDEField') as IPSDEField;
    return this.psdefield;
  }

  get psDEField(): IPSDEField | null {
    return this.getPSDEField();
  }

  getPSDEFieldMust(): IPSDEField {
    const value = this.getPSDEField();
    if (value == null) {
      throw new Error('未指定实体属性');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEFLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEFLogic' || cls == 'dataentity.logic.IPSDEFLogic') return true;
    return super.instanceof(cls);
  }
}
